package com.hj.dapp.business.role.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hj.dapp.business.role.mapper.RoleUserMapper;
import com.hj.dapp.business.role.model.RoleUser;
import com.hj.dapp.business.role.service.RoleUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 胡奥程
 * @version 1.0
 * @date 2024/1/24
 */
@Service
public class RoleUserServiceImpl implements RoleUserService {
    @Autowired
    private RoleUserMapper roleUserMapper;

    @Override
    public void deleteRoleRel(Long userId) {
        QueryWrapper<RoleUser> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId);
        roleUserMapper.delete(wrapper);
    }

    @Override
    public void bindRoleRel(Long userId, Long roleId) {
        RoleUser roleUser = new RoleUser();
        roleUser.setUserId(userId);
        roleUser.setRoleId(roleId);
        roleUserMapper.insert(roleUser);
    }
}
